<div class="tabbable tabs-left">
              <ul class="nav nav-tabs">
              	<li><h5><?php echo $this->translate('商品信息'); ?></h5></li>
                <li class="active"><a data-toggle="tab" href="#goods_a"><?php echo $this->translate('基本信息'); ?></a></li>
                <li><a data-toggle="tab" href="#goods_c"><?php echo $this->translate('商品分类'); ?></a></li>
<!--                <li><a data-toggle="tab" href="#goods_d">--><?php //echo $this->translate('商品图片'); ?><!--</a></li>-->
<!--                <li><a data-toggle="tab" href="#goods_h">--><?php //echo $this->translate('商品库存'); ?><!--</a></li>-->
<!--                <li><a data-toggle="tab" href="#goods_b">--><?php //echo $this->translate('优惠价格'); ?><!--</a></li>-->
                <li><a data-toggle="tab" href="#goods_i"><?php echo $this->translate('销售规格'); ?></a></li>
<!--                <li><a data-toggle="tab" href="#goods_k">--><?php //echo $this->translate('商品属性'); ?><!--</a></li>-->
<!--                <li><a data-toggle="tab" href="#goods_l">--><?php //echo $this->translate('商品标签'); ?><!--</a></li>-->
<!--                <li><a data-toggle="tab" href="#goods_f">--><?php //echo $this->translate('商品自定义'); ?><!--</a></li>-->
<!--                <li><a data-toggle="tab" href="#goods_n">--><?php //echo $this->translate('关联商品'); ?><!--</a></li>-->
<!--                <li><a data-toggle="tab" href="#goods_e">--><?php //echo $this->translate('相关商品'); ?><!--</a></li>-->
<!--                <li><a data-toggle="tab" href="#goods_m">--><?php //echo $this->translate('组合商品'); ?><!--</a></li>-->
<!--                --><?php //if($this->goods_info) { ?>
<!--                <li><a data-toggle="tab" href="#goods_j">--><?php //echo $this->translate('商品评价'); ?><!--</a></li>-->
<!--                --><?php //} ?>
<!--                <li><a data-toggle="tab" href="#goods_g">--><?php //echo $this->translate('搜索引擎优化'); ?><!--</a></li>-->
              </ul>
              <!--form class="form-horizontal" id="form_goods_add" method="post" onsubmit="return check_size_goods();" action="<?php //echo $this->url(($this->goods_info ? 'goodsetutor/default/goods_id' : 'goodsetutor/default'),array('action'=>($this->goods_info ? 'edit' : 'add'),'controller'=>'goods','goods_id'=>($this->goods_info ? $this->goods_info->goods_id : '0'))); ?>" -->
              <form class="form-horizontal" id="form_goods_add" method="post" onsubmit="return check_size_goods();">
              <input type="hidden" name="goods_id" id="goods_id" value="<?php echo ($this->goods_info ? $this->goods_info->goods_id : ''); ?>" />
              <input type="hidden" name="goods_save_type" id="goods_save_type" value="">
			  <input type="hidden" name="goods_spec_type" value="<?php echo ($this->goods_info ? $this->goods_info->goods_spec_type : ''); ?>">
              <div class="tab-content">
    			<div id="sticky_navigation" style="height:30px;border-bottom:4px solid #DFDFDF;">
        			<div class="pull-left" style="font-size:16px;line-height:30px;"><strong><?php if($this->goods_info) { echo $this->translate('编辑'); } else { echo $this->translate('新加');} ?><?php echo $this->translate('商品'); ?></strong></div>
        			<div id="sticky_navigation_right" class="pull-right">
                	<a href="<?php echo isset($this->goods_info) ? $this->url('goodsetutor/default/page',array('action'=>'index','controller'=>'goods', 'page'=>$this->page), array('query'=>$this->query)) : $this->url('goodsetutor/default',array('controller'=>'goods')); ?>" class="btn btn-small"><i class="icon-arrow-left"></i> <?php echo $this->translate('返回列表'); ?></a>&nbsp;
                	<a href="<?php echo $this->serverUrl(true); ?>" class="btn btn-small btn-warning"><i class="icon-repeat icon-white"></i> <?php echo $this->translate('刷新'); ?></a>&nbsp;
                    <?php if($this->goods_info) { ?>
                    <a href="javascript:;" onclick="return goods_del_js(<?php echo $this->goods_info->goods_id; ?>)" class="btn btn-small btn-danger"><i class="icon-remove icon-white"></i> <?php echo $this->translate('删除商品'); ?></a>&nbsp;
                	<button type="submit" onclick="$('#goods_save_type').val('save_return_edit');" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存商品并继续编辑'); ?></button>&nbsp;
                    <?php } ?>
                	<button type="submit" onclick="$('#goods_save_type').val('');" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存商品'); ?></button>&nbsp;
                	<a href="<?php echo $this->myviewalias()->dbshopHelpUrl('goods_set'); ?>" target="_blank" class="btn btn-small btn-info"><i class="icon-info-sign icon-white"></i> <?php echo $this->translate('查看帮助说明'); ?></a>
                	</div>
        		</div>
                <div id="goods_a" class="tab-pane active">
                	<div class="well admin_add_header_well"><?php echo $this->translate('基本信息'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品名称'); ?><span class="must_add_value">*</span>：</label>
           					<div class="controls">
              					<input type="text" id="goods_name"  name="goods_name" placeholder="<?php echo $this->translate('输入商品名称'); ?>" value="<?php echo ($this->goods_info ? $this->escapeHtml($this->goods_info->goods_name) : ''); ?>" class="span12">
            				</div>                        
                        </div>
<!--                     	<div class="control-group">-->
<!--                  			<label for="input01" class="control-label">--><?php //echo $this->translate('商品扩展名称'); ?><!--：</label>-->
<!--           					<div class="controls">-->
<!--              					<input type="text" id="goods_extend_name"  name="goods_extend_name" value="--><?php //echo ($this->goods_info ? $this->escapeHtml($this->goods_info->goods_extend_name) : ''); ?><!--" class="span12">-->
<!--            				</div>                        -->
<!--                        </div>-->
<!--                    	<div class="control-group">-->
<!--                  			<label for="input01" class="control-label">--><?php //echo $this->translate('商品货号'); ?><!--：</label>-->
<!--           					<div class="controls">-->
<!--              					<input type="text" id="goods_item"  name="goods_item" placeholder="--><?php //echo $this->translate('输入商品货号'); ?><!--" value="--><?php //echo ($this->goods_info ? $this->goods_info->goods_item : ''); ?><!--" class="span3">-->
<!--								<i class="cus-help shop_admin_help_note" data-content="--><?php //echo sprintf($this->translate('商品货号留空，会自动生成，自动生成的货号前缀到 %s系统管理->系统设置->商品设置%s 进行设置'), '<b>', '</b>'); ?><!--"></i>-->
<!--							</div>-->
<!--                        </div>-->
<!--                        <div class="control-group">-->
<!--                            <label for="input01" class="control-label">--><?php //echo $this->translate('市场价格'); ?><!--：</label>-->
<!--                            <div class="controls">-->
<!--                                <input type="text" id="goods_price"  name="goods_price" value="--><?php //echo ($this->goods_info ? $this->goods_info->goods_price : ''); ?><!--" class="span4">-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="control-group">-->
<!--                            <label for="input01" class="control-label">--><?php //echo $this->translate('价格'); ?><!--<span class="must_add_value">*</span>：</label>-->
<!--                            <div class="controls">-->
<!--                                <input type="text" id="goods_shop_price"  name="goods_shop_price" placeholder="--><?php //echo $this->translate('输入本店价格'); ?><!--" value="--><?php //echo ($this->goods_info ? $this->goods_info->goods_shop_price : ''); ?><!--" class="span4">-->
<!--                            </div>-->
<!--                        </div> -->
                        <div class="control-group" style="display: none">
                            <label for="input01" class="control-label"><?php echo $this->translate('价格'); ?><span class="must_add_value">*</span>：</label>
                            <div class="controls">
                                <input type="text" id="goods_shop_price"  name="goods_shop_price" placeholder="<?php echo $this->translate('输入本店价格'); ?>" value="0" class="span4">
                            </div>
                        </div>
<!--						<div class="control-group">-->
<!--							<label for="input01" class="control-label">--><?php //echo $this->translate('会员价格'); ?><!--：</label>-->
<!--							<div class="controls">-->
<!--								<table>-->
<!--									--><?php
//									if(isset($this->user_group) and !empty($this->user_group)) {
//										foreach($this->user_group as $userGroupValue){
//											?>
<!--											<tr>-->
<!--												<td>--><?php //echo $this->escapeHtml($userGroupValue['group_name']); ?><!--</td>-->
<!--												<td>&nbsp;<input type="text" name="user_group_price[--><?php //echo $userGroupValue['group_id']; ?><!--]" value="--><?php //echo isset($this->group_price['one_group_price'][$userGroupValue['group_id']]) ? $this->group_price['one_group_price'][$userGroupValue['group_id']] : 0; ?><!--" class="span10"></td>-->
<!--											</tr>-->
<!--											--><?php
//										}
//									}
//									?>
<!--								</table>-->
<!--							</div>-->
<!--						</div>-->
<!--						<div class="control-group">-->
<!--							<label for="input01" class="control-label">--><?php //echo $this->translate('商品类型'); ?><!--<span class="must_add_value">*</span>：</label>-->
<!--							<div class="controls">-->
<!--								<select name="goods_type" id="goods_type" class="span2">-->
<!--									<option value="">--><?php //echo $this->translate('选择类型'); ?><!--</option>-->
<!--									<option value="1" --><?php //if (($this->goods_info and $this->goods_info->goods_type==1) or !isset($this->goods_info->goods_type)) { ?><!--selected="selected"--><?php //} ?><!--><?php //echo $this->translate('实物商品'); ?><!--</option>-->
<!--									<option value="2" --><?php //if ($this->goods_info and $this->goods_info->goods_type==2) { ?><!--selected="selected"--><?php //} ?><!--><?php //echo $this->translate('虚拟商品'); ?><!--</option>-->
<!--								</select>-->
<!--								<i class="cus-help shop_admin_help_note" data-content="--><?php //echo $this->translate('虚拟商品需要保存后，在商品列表中，找到该商品进行具体的虚拟商品信息添加。'); ?><!--"></i>-->
<!--							</div>-->
<!--						</div>-->
                        <div class="control-group" style="display: none">
							<label for="input01" class="control-label"><?php echo $this->translate('商品类型'); ?><span class="must_add_value">*</span>：</label>
							<div class="controls">
								<select name="goods_type" id="goods_type" class="span2">
									<option value=""><?php echo $this->translate('选择类型'); ?></option>
									<option value="1" selected="selected"><?php echo $this->translate('实物商品'); ?></option>
<!--									<option value="2" --><?php //if ($this->goods_info and $this->goods_info->goods_type==2) { ?><!--selected="selected"--><?php //} ?><!--><?php //echo $this->translate('虚拟商品'); ?><!--</option>-->
								</select>
								<i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('虚拟商品需要保存后，在商品列表中，找到该商品进行具体的虚拟商品信息添加。'); ?>"></i>
							</div>
						</div>
<!--						<div class="control-group">-->
<!--							<label for="input01" class="control-label">--><?php //echo $this->translate('积分购买'); ?><!--：</label>-->
<!--							<div class="controls">-->
<!--								<input type="text" id="goods_integral_num" readonly name="goods_integral_num" placeholder="--><?php //echo $this->translate('输入购买该商品需要的积分数'); ?><!--" value="--><?php //echo ($this->goods_info ? intval($this->goods_info->goods_integral_num) : '0'); ?><!--" class="span2">-->
<!--								<button type="button" class="btn btn-small btn-primary" onclick="price_change_integral('goods_shop_price', 'goods_integral_num');">--><?php //echo $this->translate('点击将价格换算为积分'); ?><!--</button>-->
<!--								<button type="button" class="btn btn-small btn-danger" onclick="$('#goods_integral_num').val(0);">--><?php //echo $this->translate('点击取消积分购买'); ?><!--</button>-->
<!--								<i class="cus-help shop_admin_help_note" data-content="--><?php //echo $this->translate('当积分数为0该商品不支持积分购买，如果这里输入的积分大于0，则该商品支持积分购买，这里的积分指的是 消费积分。'); ?><!--"></i>-->
<!--								<a href="--><?php //echo $this->url('integral/default/integral_type_id',array('action'=>'integralTypeEdit', 'integral_type_id'=>1)); ?><!--" target="_blank">--><?php //echo $this->translate('点击去设置积分与基础货币换算比例'); ?><!--</a>-->
<!--							</div>-->
<!--						</div>-->
<!--                    	<div class="control-group">-->
<!--                  			<label for="input01" class="control-label">--><?php //echo $this->translate('商品品牌'); ?><!--：</label>-->
<!--           					<div class="controls">-->
<!--                            	<select name="brand_id" id="brand_id" class="span2">-->
<!--                                <option value="0">--><?php //echo $this->translate('选择品牌'); ?><!--</option>-->
<!--                                --><?php
//                                if ($this->goods_brand) {
//									foreach($this->goods_brand as $brand_val) {
//								?>
<!--								<option value="--><?php //echo $brand_val['brand_id']; ?><!--" --><?php //if ($this->goods_info and $brand_val['brand_id']==$this->goods_info->brand_id) { ?><!--selected="selected"--><?php //} ?><!--><?php //echo $this->escapeHtml($brand_val['brand_name']); ?><!--</option>-->
<!--                                --><?php
//									}
//								}
//								?>
<!--                                </select>-->
<!--            				</div>                        -->
<!--                        </div>-->
<!--						<div class="control-group">-->
<!--							<label for="input01" class="control-label">--><?php //echo $this->translate('虚拟销量'); ?><!--：</label>-->
<!--							<div class="controls">-->
<!--								<input type="text" id="virtual_sales"  name="virtual_sales" placeholder="--><?php //echo $this->translate('输入虚拟销量'); ?><!--" value="--><?php //echo ($this->goods_info ? intval($this->goods_info->virtual_sales) : 0); ?><!--" class="span2">-->
<!--								<i class="cus-help shop_admin_help_note" data-content="--><?php //echo $this->translate('PC前端体现在商品详情页面中的购买人数；PHONE端体现在销量上。'); ?><!--"></i>-->
<!--							</div>-->
<!--						</div>-->
<!--                    	<div class="control-group">-->
<!--                  			<label for="input01" class="control-label">--><?php //echo $this->translate('商品重量'); ?><!--：</label>-->
<!--           					<div class="controls">-->
<!--              					<input type="text" id="goods_weight"  name="goods_weight" value="--><?php //echo ($this->goods_info ? $this->goods_info->goods_weight : ''); ?><!--" class="span2"> --><?php //echo $this->translate('千克'); ?>
<!--            				</div>                        -->
<!--                        </div>-->
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品状态'); ?>：</label>
           					<div class="controls">
              					<select id="goods_state" name="goods_state" class="span2">
                                <option value="1" <?php if($this->goods_info and $this->goods_info->goods_state == 1) echo 'selected="selected"'; ?>><?php echo $this->translate('上架'); ?></option>
                                <option value="2" <?php if($this->goods_info and $this->goods_info->goods_state == 2) echo 'selected="selected"'; ?>><?php echo $this->translate('下架'); ?></option>
                                </select>
            				</div>                        
                        </div>
                    	<div class="control-group" style="display: none">
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品详述'); ?>：</label>
           					<div class="controls">
              					<script type="text/plain" id="goods_body" name="goods_body"><?php echo ($this->goods_info ? $this->goods_info->goods_body : ''); ?></script>
            				</div>                        
                        </div>
                      
                  	</div>
                </div>
                <div id="goods_b" class="tab-pane" style="display: none">
                	<div class="well admin_add_header_well"><?php echo $this->translate('优惠价格'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('优惠价格'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="goods_preferential_price"  name="goods_preferential_price" value="<?php echo ($this->goods_info ? $this->goods_info->goods_preferential_price : ''); ?>" class="span4"> <i class="cus-help shop_admin_help_note" data-content="<?php echo sprintf($this->translate('当设置了优惠价格，且在下面的优惠时间内，则购买商品价格都为优惠价格，%s即使销售价格中设置了不同规格的价格，也无效。需要等优惠期过后，才有效。%s'),'<strong>','</strong>'); ?>"></i>
            				</div>                        
                        </div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('优惠开始时间'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="goods_preferential_start_time"  name="goods_preferential_start_time" value="<?php if ($this->goods_info and $this->goods_info->goods_preferential_start_time != '') echo date("Y-m-d H:i",$this->goods_info->goods_preferential_start_time); ?>" onclick="WdatePicker({el:'goods_preferential_start_time', dateFmt:'yyyy-MM-dd HH:mm'})" class="span2 Wdate"> <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('当优惠价价格为有效价格时，在此设置时间才有效，为空，则不限时间。'); ?>"></i>
            				</div>                        
                        </div> 
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('优惠结束时间'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="goods_preferential_end_time"  name="goods_preferential_end_time" value="<?php if ($this->goods_info and $this->goods_info->goods_preferential_end_time != '') echo date("Y-m-d H:i",$this->goods_info->goods_preferential_end_time); ?>" onclick="WdatePicker({el:'goods_preferential_end_time', dateFmt:'yyyy-MM-dd HH:mm'})" class="span2 Wdate"> <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('当优惠价价格为有效价格时，在此设置时间才有效，为空，则不限时间。'); ?>"></i>
            				</div>                        
                        </div>
                     	<!-- <div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('客户组价格'); ?>：</label>
           					<div class="controls">
              					
            				</div>                        
                        </div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('购物数价格'); ?>：</label>
           					<div class="controls">
              					
            				</div>                        
                        </div> -->            
                  	</div>
                </div>
                 <div id="goods_i" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('销售规格'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                        <?php if(empty($this->goods_spec_tag_group)) { ?>
                            <div class="alert alert-info" style="margin-bottom: 20px;">
                                <strong><?php echo $this->translate('暂无规格信息，首先在 商品标签->商品标签分组 中设置规格组，然后在 商品标签->普通商品标签 中设置对应规格组的规格信息。'); ?></strong>
                            </div>
                        <?php } ?>

						<?php $goods_spec_default_type = $this->frontwebsite()->getDbshopGoodsIni('goods_spec'); ?>
						<?php if ($goods_spec_default_type > 0 and (isset($this->goods_info->goods_spec_type) and $goods_spec_default_type != $this->goods_info->goods_spec_type)) { ?>
                        <div class="control-group">
                            <label for="input01" class="control-label"><?php echo $this->translate('切换规格模式'); ?>：</label>
                            <div class="controls">
								<?php if ($this->goods_info->goods_spec_type == 2) { ?>
									<a href="<?php echo $this->url('goodsetutor/default',array('action'=>'changeGoodsSpecType','controller'=>'goods'), array('query'=>array('specType'=>1, 'goods_id'=>$this->goods_info->goods_id))); ?>" onclick="return confirm('<?php echo $this->translate('切换规格模式会刷新当前页面，当前的规格信息会被清除！'); ?>');" class="btn btn-small btn-primary"><?php echo $this->translate('切换到普通规格模式'); ?></a>
								<?php } else { ?>
									<a href="<?php echo $this->url('goodsetutor/default',array('action'=>'changeGoodsSpecType','controller'=>'goods'), array('query'=>array('specType'=>2, 'goods_id'=>$this->goods_info->goods_id))); ?>" onclick="return confirm('<?php echo $this->translate('切换规格模式会刷新当前页面，当前的规格信息会被清除！'); ?>');" class="btn btn-small btn-primary"><?php echo $this->translate('切换到高级规格模式'); ?></a>
								<?php } ?>
                            </div>
                        </div>
						<?php } ?>
                        <?php if(!empty($this->goods_spec_tag_group)) { ?>
						<div class="control-group">
							<label for="input01" class="control-label"><?php echo $this->translate('选择规格组'); ?>：</label>
							<div class="controls goods_color_select">
								<table class="table table-condensed">
									<?php
										foreach($this->goods_spec_tag_group as $spec_value) {
										?>
										<label class="checkbox inline"><input type="checkbox" name="goods_spec_tag_group[]" id="goods_spec_tag_group_<?php echo $spec_value['tag_group_id']; ?>" value="<?php echo $spec_value['tag_group_id']; ?>" onclick="select_goods_spec_tag_group(<?php echo $spec_value['tag_group_id']; ?>, '<?php echo $this->escapeHtml($spec_value['tag_group_name']); ?>');" <?php if(isset($this->selected_spec_group_id) and !empty($this->selected_spec_group_id) and in_array($spec_value['tag_group_id'], $this->selected_spec_group_id)) echo 'checked'; ?>><span id="goods_spec_tag_group_name_<?php echo $spec_value['tag_group_id']; ?>"><?php echo $this->escapeHtml($spec_value['tag_group_name']); ?></span><?php echo (!empty($spec_value['tag_group_mark']) ? '['.$spec_value['tag_group_mark'].']' : ''); ?></label>
									<?php } ?>
								</table>
							</div>
						</div>
						<hr>
						<div id="select_goods_spec_tag">
							<?php
                            $spec_goods_tag_state = false;
							$spec_tag_value_array = array();
							if(isset($this->spec_goods_tag_array) and !empty($this->spec_goods_tag_array)) {
							    $spec_goods_tag_state = true;
								foreach($this->spec_goods_tag_array as $spec_goods_v) {
							?>
							<div class="control-group" id="select_tag_group_<?php echo $spec_goods_v['spec_tag_group_id']; ?>">
								<label for="input01" class="control-label"><?php echo $this->escapeHtml($spec_goods_v['spec_tag_group_name']); ?>：</label>
								<div class="controls">
									<?php
									if(!empty($spec_goods_v['spec_tag_value_array'])) {
										foreach($spec_goods_v['spec_tag_value_array'] as $s_t_v) {
										?>
										<label class="checkbox inline"><input type="checkbox" <?php if(!empty($spec_goods_v['selected_spec_tag_id_array']) and in_array($s_t_v['tag_id'], $spec_goods_v['selected_spec_tag_id_array'])) echo 'checked'; ?> name="spec_goods_tag_<?php echo $spec_goods_v['spec_tag_group_id']; ?>[]" id="spec_goods_tag_<?php echo $spec_goods_v['spec_tag_group_id']; ?>_<?php echo $s_t_v['tag_id']; ?>" value="<?php echo $s_t_v['tag_id']; ?>" onclick="add_goods_spec_tag(<?php echo $s_t_v['tag_id']; ?>, <?php echo $spec_goods_v['spec_tag_group_id']; ?>, '<?php echo $s_t_v['tag_name']; ?>', '<?php echo $this->escapeHtml($spec_goods_v['spec_tag_group_name']); ?>');">
										<?php if(!empty($s_t_v['tag_str'])) { ?>
											<span style="background-color: <?php echo $s_t_v['tag_str']; ?>;height: 14px;width: 14px;border: 1px solid #E4E4E4;display:inline-block;line-height: 20px;vertical-align: middle;"></span>
										<?php } ?>
										<span id="name<?php echo $s_t_v['tag_id']; ?>"><?php echo $this->escapeHtml($s_t_v['tag_name']); ?></span></label>
										<?php $spec_tag_value_array[$s_t_v['tag_id']] = $s_t_v['tag_name']; ?>
									<?php } } ?>
								</div>
							</div>
							<?php } } ?>
						</div>
						<hr>
						<table class="table table-bordered" style="width:98%;<?php if($this->price_goods_array and !empty($this->price_goods_array)) echo ''; else echo 'display:none;'; ?>" id="select_goods_color_size_in">
							<thead style="background:#CCC;" id="goods_spec_th">
                                <?php
                                if($spec_goods_tag_state) {
									foreach($this->spec_goods_tag_array as $spec_goods_v) {
                                ?>
								<th width="8%"><?php echo $this->escapeHtml($spec_goods_v['spec_tag_group_name']); ?></th>
                                <?php } } ?>
								<th width="12%"><?php echo $this->translate('价格'); ?><span class="must_add_value">*</span>&nbsp;<input type="text" class="span8" id="spec_tag_goods_price" onblur="edit_price_stock('spec_tag_goods_price', 'price');" /></th>
								<th width="10%"><?php echo $this->translate('库存'); ?><span class="must_add_value">*</span>&nbsp;<input type="text" class="span8" id="spec_tag_goods_stock" onblur="edit_price_stock('spec_tag_goods_stock', 'stock');" /></th>
								<th width="10%" style="vertical-align:middle;"><?php echo $this->translate('商品货号'); ?>&nbsp;<input type="text" class="span5" id="edit_goods_item" onblur="edit_goods_item_all();" /></th>
                                <th width="8%"><?php echo $this->translate('积分购买'); ?></th>
                                <th width="15%"><?php echo $this->translate('会员价格'); ?></th>
							</thead>
							<tbody id="goods_spec_td">
								<?php
								 if($spec_goods_tag_state) {
									foreach($this->price_goods_array as $price_goods_value) {
										$tag_id_str = str_replace(',', '_', $price_goods_value['adv_spec_tag_id']);	 
								?>
								<tr>
								<?php
								$tag_str_array = unserialize($price_goods_value['spec_tag_id_serialize']);
								foreach($this->spec_goods_tag_array as $spec_goods_v) {
								?>
								<td><?php echo $spec_tag_value_array[$tag_str_array[$spec_goods_v['spec_tag_group_id']]]; ?></td>
								<?php } ?>
								<td>
									<input type="hidden" name="spec_tag_id_str[]" value="_<?php echo $tag_id_str; ?>">
									<input type="text" name="spec_goods_price[]" id="price_<?php echo $tag_id_str; ?>" value="<?php echo $price_goods_value['goods_extend_price']; ?>">
								</td>
								<td><input type="text" name="spec_goods_stock[]" id="stock_<?php echo $tag_id_str; ?>" value="<?php echo $price_goods_value['goods_extend_stock']; ?>"></td>
								<td><input type="text" name="spec_goods_item[]" id="item_<?php echo $tag_id_str; ?>" value="<?php echo $price_goods_value['goods_extend_item']; ?>"></td>
                                    <td>
                                        <input type="text" readonly value="<?php echo $price_goods_value['goods_extend_integral']; ?>" name="integral_num[]" id="integral_num_<?php echo $tag_id_str; ?>">
                                        <p><button type="button" class="btn btn-small btn-primary" onclick="price_change_integral('price_<?php echo $tag_id_str; ?>','integral_num_<?php echo $tag_id_str; ?>');"><?=$this->translate('换算'); ?></button>&nbsp;
                                            <button type="button" class="btn btn-small btn-danger" onclick="$('#integral_num_<?php echo $tag_id_str; ?>').val(0);"><?=$this->translate('取消'); ?></button></p>
                                    </td>
                                    <td>
                                    <?php
                                    if(isset($this->user_group) and !empty($this->user_group)) {
                                        ?>
                                        <table style="border: 1px solid #ddd;width: 100%;">
                                            <?php
                                            foreach($this->user_group as $userGroupValue){
                                                ?>
                                                <tr>
                                                    <td><?php echo $this->escapeHtml($userGroupValue['group_name']); ?></td>
                                                    <td><input type="text" id="groupprice_<?php echo $tag_id_str.'_'.$userGroupValue['group_id']; ?>" name="spec_goods_group_price[_<?php echo $tag_id_str; ?>][<?php echo $userGroupValue['group_id']; ?>]" value="<?php echo isset($this->group_price['color_size_group_price'][$tag_id_str][$userGroupValue['group_id']]) ? $this->group_price['color_size_group_price'][$tag_id_str][$userGroupValue['group_id']] : 0; ?>"></td>
                                                </tr>
                                            <?php } ?>
                                        </table>
                                    <?php } ?>
                                </td>
								<tr>
								<?php } } ?>
							</tbody>
						</table>
                        <?php } ?>
                  	</div>
                </div>
                <div id="goods_c" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('商品分类'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                        <?php
                        if ($this->goods_class) {
                            ?>
                            <div class="alert alert-info" style="margin-top: 2px;">
                                <strong><?php echo $this->translate('说明：商品主分类 用来精确统计商品销量及对应分类销量使用，防止统计数据出现误差。如 一件女士裙装 它的所属分类层级是 文章服务->高中文章定制写作 那么这个 高中文章定制写作 分类就是该商品的主分类。'); ?></strong>
                            </div>
                            <table width="95%" class="table-hover">
                                <thead>
                                <tr>
                                    <th width="80%" height="36px" align="left"><?php echo $this->translate('选择商品分类'); ?></th>
                                    <th width="15%" align="left"><?php echo $this->translate('选择商品主分类'); ?></th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                foreach ($this->goods_class as $class_val) {
                                    ?>
                                    <tr>
                                        <td><label class="checkbox" style="margin-left:<?php echo $class_val['class_level'] * 20; ?>px;"><input <?php if($class_val['class_top_id'] != 0) echo 'onclick="select_goods_class(\''.$class_val['class_path'].'\', '.$class_val['class_id'].');"'; ?> type="checkbox" name="class_id[]" id="class_id_<?php echo $class_val['class_id']; ?>" value="<?php echo $class_val['class_id']; ?>" <?php if(($this->in_class and in_array($class_val['class_id'],$this->in_class) or $this->get_class_id == $class_val['class_id'])) { ?>checked="checked"<?php } ?>><?php echo $this->escapeHtml($class_val['class_name']); ?> <?php if($class_val['class_state'] == 0) echo ' [<font color="red"><strong>'.$this->translate('已禁用').'</strong></font>]'; ?></label></td>
                                        <td><label class="checkbox"><input type="radio" name="main_class_id" value="<?php echo $class_val['class_id']; ?>" <?php if(isset($this->goods_info->main_class_id) and $this->goods_info->main_class_id == $class_val['class_id']) echo 'checked'; ?>></label></td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        <?php } else { ?>
                            <label><?php echo $this->translate('还没有商品分类'); ?> <a href="<?php echo $this->url('class/default',array('action'=>'add','controller'=>'class')); ?>" class="btn btn-small btn-primary"><i class="icon-plus icon-white"></i> <?php echo $this->translate('马上去创建商品分类'); ?></a></label>
                        <?php } ?>
                  	</div>
                </div>
                <div id="goods_h" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('商品库存'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('库存数量'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="goods_stock"  name="goods_stock" value="<?php echo ($this->goods_info ? $this->goods_info->goods_stock : '10'); ?>" class="span4">
            				</div>                        
                        </div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('库存状态'); ?>：</label>
           					<div class="controls">
              					<select class="span2" name="goods_stock_state" id="goods_stock_state">
                                <?php if($this->stock_state_array) foreach ($this->stock_state_array as $stock_state_value) {
											if($stock_state_value['stock_type_state'] == 2) continue;
									?>
                                <option value="<?php echo $stock_state_value['stock_state_id']; ?>"
								<?php if($this->goods_info and $this->goods_info->goods_stock_state == $stock_state_value['stock_state_id']) echo 'selected="selected"';
								elseif ($stock_state_value['state_type'] == 1 and !$this->goods_info) echo 'selected="selected"'; ?> ><?php echo $stock_state_value['stock_state_name']; ?></option>
                                <?php } ?>
                                </select>
                                <label class="checkbox inline"><input type="checkbox" name="goods_stock_state_open" value="1" <?php if($this->goods_info) { echo ($this->goods_info->goods_stock_state_open == 1 ? 'checked="checked"' : ''); } else { echo 'checked="checked"'; } ?> ><?php echo $this->translate('启用'); ?></label>
                                 <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('当启用了库存状态，前台库存显示下拉菜单选中的文字，不显示库存数量，同时正常购物库存不减少！'); ?>"></i>
            				</div>                        
                        </div> 
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品缺货时数量'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="goods_out_of_stock_set"  name="goods_out_of_stock_set" value="<?php echo ($this->goods_info ? $this->goods_info->goods_out_of_stock_set : ''); ?>" class="span4">
            				</div>                        
                        </div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('缺货状态'); ?>：</label>
           					<div class="controls">
              					<select class="span2" name="goods_out_stock_state" id="goods_out_stock_state">
                                <?php if($this->stock_state_array) foreach ($this->stock_state_array as $stock_state_value) {
											if($stock_state_value['stock_type_state'] == 1) continue;
								?>
                                <option value="<?php echo $stock_state_value['stock_state_id']; ?>"
								<?php if($this->goods_info and $this->goods_info->goods_out_stock_state == $stock_state_value['stock_state_id']) echo 'selected="selected"';
								elseif ($stock_state_value['state_type'] == 1 and !$this->goods_info) echo 'selected="selected"'; ?> ><?php echo $stock_state_value['stock_state_name']; ?></option>
                                <?php } ?>
                                </select>
                                <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('前台商品缺货状态下显示的文字！'); ?>"></i>
            				</div>                        
                        </div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('购物车购买最少数量'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="goods_cart_buy_min_num"  name="goods_cart_buy_min_num"  value="<?php echo ($this->goods_info ? $this->goods_info->goods_cart_buy_min_num : ''); ?>" class="span4">
            				</div>                        
                        </div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('购物车购买最多数量'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="goods_cart_buy_max_num"  name="goods_cart_buy_max_num"  value="<?php echo ($this->goods_info ? $this->goods_info->goods_cart_buy_max_num : ''); ?>" class="span4">
            				</div>                        
                        </div>
                                         
                  	</div>
                </div> 
                 <div id="goods_d" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('商品图片'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                        <script src="<?php echo $this->basePath('/public/js/newuploadify/jquery.uploadifive.min.js'); ?>" type="text/javascript"></script>
                        <link rel="stylesheet" type="text/css" href="<?php echo $this->basePath('/public/js/newuploadify/uploadifive.css'); ?>">
                    <div id="queue"></div>
                    <button type="button" class="pull-right btn btn-small btn-primary" onclick="get_editor_new_image(<?php echo ($this->goods_info ? $this->goods_info->goods_id : 0); ?>);"><i class="icon-magnet icon-white"></i> <?php echo $this->translate('点击获取在编辑器中新上传的商品图片'); ?></button>
                    <input id="file_upload" name="file_upload" type="file" multiple="true">

                	<div id="image_message_one">
                    </div>

               		<table class="table table-hover" id="goods_more_image">
                    <thead style="background:#CCC;">
                    	<th width="10%"><?php echo $this->translate('图片'); ?></th>
                        <th width="20%"><?php echo $this->translate('图片名称'); ?></th>
                        <th width="10%"><?php echo $this->translate('封面图片'); ?></th>
                        <th width="5%"><?php echo $this->translate('切换显示'); ?> <i class="cus-help shop_admin_help_note" data-content="<?php echo$this->translate('前台模板的商品详细页面，有切换效果时，显示；这里的设置并不影响图片的显示，这个选项只是针对切换效果。'); ?>"></i></th>
                        <th width="10%"><?php echo $this->translate('图片排序'); ?></th>
                        <th width="10%"><?php echo $this->translate('操作'); ?></th>
                    </thead>
               		<?php
               		if($this->goods_images) {
               			foreach ($this->goods_images as $image) {
               		?>
               		<tr id="image_<?php echo $image->goods_image_id; ?>">
               		<td><img src="<?php echo $this->basePath($this->frontwebsite()->shopadminGoodsImage($image->goods_thumbnail_image)); ?>" style="width: 100px;" border="0"></td>
               		<td style="vertical-align:middle"><?php  $image_array = array();$image_array = pathinfo($image->goods_title_image); echo $image_array['basename']; ?><input type="hidden" name="image_more[]" value="<?php echo $image->goods_image_id; ?>"></td>
               		<td style="vertical-align:middle"><input type="radio" name="default_image" <?php if ($this->goods_info and $this->goods_info['goods_image_id']==$image->goods_image_id) { ?>checked="checked"<?php } ?> value="<?php echo $image->goods_image_id; ?>"></td>
                    <td style="vertical-align:middle"><label class="checkbox"><input type="checkbox" <?php if (isset($image->image_slide) and $image->image_slide==1) { ?>checked="checked"<?php } ?> name="image_slide_<?php echo $image->goods_image_id; ?>" id="image_slide_<?php echo $image->goods_image_id; ?>" onclick="edit_image_slide_state(<?php echo $image->goods_image_id; ?>, 'image_slide_<?php echo $image->goods_image_id; ?>');" value="1"></label></td>
                    <td style="vertical-align:middle"><input type="text" class="span4" value="<?php echo $image->image_sort; ?>" name="image_sort_<?php echo $image->goods_image_id; ?>" id="image_sort_<?php echo $image->goods_image_id; ?>" /></td>
               		<td style="vertical-align:middle">
                    <a href="javascript:;" onclick="edit_goods_image(<?php echo $image->goods_image_id; ?>,'image_sort_<?php echo $image->goods_image_id; ?>','image_slide_<?php echo $image->goods_image_id; ?>','<?php echo $image_array['basename']; ?>');" class="btn btn-small btn-primary"><i class="icon-refresh icon-white"></i> <?php echo $this->translate('更新'); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:;" onclick="del_goods_image(<?php echo $image->goods_image_id,',\''.$image_array['basename'].'\''; ?>);" class="btn btn-small btn-danger"><i class="icon-trash icon-white"></i> <?php echo $this->translate('删除'); ?></a>
                    </td>
               		</tr>
               		<?php
               			}
               		}
               		?>
               		</table>

                  	</div>
                </div>
                 <div id="goods_e" class="tab-pane" style="display: none">
                	<div class="well admin_add_header_well"><?php echo $this->translate('相关商品'); ?></div>
                	<div class="well admin_add_well">
						<?php if($this->goods_info) { ?>
                	    <div class="message_one">
                    	</div>
                        <div class="control-group">
              			<input type="text" placeholder="<?php echo $this->translate('请输入需要添加的商品部分或者全部名称'); ?>" id="related_goods_keyword" name="related_goods_keyword"  value="" class="span5"><input type="hidden" name="relatedgoods_id" id="relatedgoods_id" value="" />&nbsp;&nbsp;<button type="button" onclick="add_related_goods_js();" class="btn btn-small btn-primary"><i class="icon-plus icon-white"></i> <?php echo $this->translate('点击添加相关商品'); ?></button>
            			<i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('在输入框中输入商品部分或者全部名称，然后点击添加按钮，即可添加相关商品'); ?>"></i>
						[<?php echo $this->translate('如果您不添加，系统将在前台自动随机显示该商品的相关其他商品。'); ?>]
                       </div>
            <table class="table table-hover" id="related_goods_table">
            <thead style="background:#CCC;">
            	<tr>
                    <th width="5%">ID</th>
                    <th width="35%"><?php echo $this->translate('商品名称'); ?></th>
                    <th width="12%"><?php echo $this->translate('商品货号'); ?></th>
                    <th width="12%"><?php echo $this->translate('商品价格'); ?></th>
                    <th width="7%"><?php echo $this->translate('状态'); ?></th>
                    <th width="6%"><?php echo $this->translate('操作'); ?></th>
                </tr>
            </thead>
            <?php if ($this->related_goods_array) {
				foreach($this->related_goods_array as $related_goods_value) {
			?>
            <tr id="show_related_goods_<?php echo $related_goods_value['related_id']; ?>">
            	<td><?php echo $related_goods_value['related_goods_id']; ?></td>
            	<td><?php echo $this->escapeHtml($related_goods_value['goods_name']); ?></td>
            	<td><?php echo $related_goods_value['goods_item']; ?></td>
            	<td><?php echo $related_goods_value['goods_shop_price']; ?></td>
            	<td><?php echo $related_goods_value['goods_state'] == 1 ? $this->translate('上架') : $this->translate('下架'); ?></td>
            	<td><a href="javascript:;" onclick="delete_related_goods(<?php echo $related_goods_value['related_id']; ?>);"><?php echo $this->translate('删除'); ?></a></td>
            </tr>
            <?php } } ?>
            </table>
			<?php } else { ?>
				<div><?php echo $this->translate('本操作，需要您保存商品后再进行该设置！'); ?></div>
			<?php } ?>
                  	</div>
                </div>
                 <div id="goods_f" class="tab-pane" style="display: none">
                	<div class="well admin_add_header_well"><?php echo $this->translate('商品自定义'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                        <?php for($i=1; $i<=10; $i++) { ?>
                            <div class="control-group">
                                <label for="input01" class="control-label"><input type="text" class="span10" value="<?php if(isset($this->goods_custom[$i]['custom_title']) and !empty($this->goods_custom[$i]['custom_title'])) echo $this->escapeHtml($this->goods_custom[$i]['custom_title']); ?>" name="custom_title[<?php echo $i; ?>]" style="text-align:right">：</label>
                                <div class="controls">
                                    <input type="text" name="custom_content[<?php echo $i; ?>]" value="<?php if(isset($this->goods_custom[$i]['custom_content']) and !empty($this->goods_custom[$i]['custom_content'])) echo $this->escapeHtml($this->goods_custom[$i]['custom_content']); ?>" class="span8" style="margin-top:5px;">
                                    &nbsp;&nbsp;&nbsp;<label class="checkbox inline"><input type="checkbox" name="custom_content_state[<?php echo $i; ?>]" value="1" <?php if(isset($this->goods_custom[$i]['custom_content_state']) and $this->goods_custom[$i]['custom_content_state'] == 1) echo 'checked';  ?>><?php echo $this->translate('前台显示'); ?></label>
                                </div>
                            </div>
                        <?php } ?>

                  	</div>
                </div>

				  <div id="goods_n" class="tab-pane" style="display: none">
					  <div class="well admin_add_header_well"><?php echo $this->translate('关联商品'); ?></div>
					  <div class="well admin_add_well">
						  <?php if($this->goods_info) { ?>
							  <div class="message_one">
							  </div>
							  <div class="control-group">
								  <input type="text" placeholder="<?php echo $this->translate('请输入需要添加的商品部分或者全部名称'); ?>" id="relation_goods_keyword" name="relation_goods_keyword"  value="" class="span5"><input type="hidden" name="relationgoods_id" id="relationgoods_id" value="" />&nbsp;&nbsp;<button type="button" onclick="add_relation_goods_js();" class="btn btn-small btn-primary"><i class="icon-plus icon-white"></i> <?php echo $this->translate('点击添加关联商品'); ?></button>
								  <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('在输入框中输入商品部分或者全部名称，然后点击添加按钮，即可添加关联商品'); ?>"></i>
							  </div>
							  <table class="table table-hover" id="relation_goods_table">
								  <thead style="background:#CCC;">
								  <tr>
									  <th width="5%">ID</th>
									  <th width="35%"><?php echo $this->translate('商品名称'); ?></th>
									  <th width="12%"><?php echo $this->translate('商品货号'); ?></th>
									  <th width="12%"><?php echo $this->translate('商品价格'); ?></th>
									  <th width="7%"><?php echo $this->translate('状态'); ?></th>
									  <th width="7%"><?php echo $this->translate('排序'); ?></th>
									  <th width="6%"><?php echo $this->translate('操作'); ?></th>
								  </tr>
								  </thead>
								  <?php if ($this->relation_goods_array) {
									  foreach($this->relation_goods_array as $relation_goods_value) {
										  ?>
										  <tr id="show_relation_goods_<?php echo $relation_goods_value['relation_id']; ?>">
											  <td><?php echo $relation_goods_value['relation_goods_id']; ?></td>
											  <td><?php echo $this->escapeHtml($relation_goods_value['goods_name']); ?></td>
											  <td><?php echo $relation_goods_value['goods_item']; ?></td>
											  <td><?php echo $relation_goods_value['goods_shop_price']; ?></td>
											  <td><?php echo $relation_goods_value['goods_state'] == 1 ? $this->translate('上架') : $this->translate('下架'); ?></td>
											  <td><input type="text" name="relation_sort[<?php echo $relation_goods_value['relation_id']; ?>]" value="<?php echo $relation_goods_value['relation_sort']; ?>"></td>
											  <td><a href="javascript:;" onclick="delete_relation_goods(<?php echo $relation_goods_value['relation_id']; ?>);"><?php echo $this->translate('删除'); ?></a></td>
										  </tr>
									  <?php } } ?>
							  </table>
						  <?php } else { ?>
							  <div><?php echo $this->translate('本操作，需要您保存商品后再进行该设置！'); ?></div>
						  <?php } ?>
					  </div>
				  </div>

                 <div id="goods_m" class="tab-pane" style="display: none">
                	<div class="well admin_add_header_well"><?php echo $this->translate('组合商品'); ?></div>
                	<div class="well admin_add_well">
						<?php if($this->goods_info) { ?>
                	    <div class="message_one">
                    	</div>
                        <div class="control-group">
              			<input type="text" placeholder="<?php echo $this->translate('请输入需要添加的商品部分或者全部名称'); ?>" id="combination_goods_keyword" name="combination_goods_keyword"  value="" class="span5"><input type="hidden" name="combination_goods_id" id="combination_goods_id" value="" />&nbsp;&nbsp;<button type="button" onclick="add_combination_goods_js();" class="btn btn-small btn-primary"><i class="icon-plus icon-white"></i> <?php echo $this->translate('点击添加组合商品'); ?></button>
            			<i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('在输入框中输入商品部分或者全部名称，然后点击添加按钮，即可添加组合商品'); ?>"></i>
                       </div>
            <table class="table table-hover" id="combination_goods_table">
            <thead style="background:#CCC;">
            	<tr>
                    <th width="5%">ID</th>
                    <th width="35%"><?php echo $this->translate('商品名称'); ?></th>
                    <th width="12%"><?php echo $this->translate('商品货号'); ?></th>
                    <th width="12%"><?php echo $this->translate('商品价格'); ?></th>
                    <th width="7%"><?php echo $this->translate('状态'); ?></th>
                    <th width="6%"><?php echo $this->translate('操作'); ?></th>
                </tr>
            </thead>
            <?php if ($this->combination_goods_array) {
				foreach($this->combination_goods_array as $combination_goods_value) {
			?>
            <tr id="show_combination_goods_<?php echo $combination_goods_value['combination_id']; ?>">
            	<td><?php echo $combination_goods_value['combination_goods_id']; ?></td>
            	<td><?php echo $this->escapeHtml($combination_goods_value['goods_name']); ?></td>
            	<td><?php echo $combination_goods_value['goods_item']; ?></td>
            	<td><?php echo $combination_goods_value['goods_shop_price']; ?></td>
            	<td><?php echo $combination_goods_value['goods_state'] == 1 ? $this->translate('上架') : $this->translate('下架'); ?></td>
            	<td><a href="javascript:;" onclick="delete_combination_goods(<?php echo $combination_goods_value['combination_id']; ?>);"><?php echo $this->translate('删除'); ?></a></td>
            </tr>
            <?php } } ?>
            </table>
			<?php } else { ?>
				<div><?php echo $this->translate('本操作，需要您保存商品后再进行该设置！'); ?></div>
			<?php } ?>
                  	</div>
                </div>
				<div id="goods_l" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('商品标签'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
              			<?php if ($this->goods_tag_group) {
							foreach($this->goods_tag_group as $tag_group_key => $tag_group) {
						?>                        
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php if ($tag_group == '') echo $this->translate('未分组'); else echo $tag_group; ?>：</label>
           					<div class="controls">
              					<?php if ($this->goods_tag[$tag_group_key]) {
									foreach($this->goods_tag[$tag_group_key] as $tag_val) {
								?>
                                <label class="checkbox inline"><input type="checkbox" name="tag_id[]" id="tag_id_<?php echo $tag_val['tag_id']; ?>" <?php if ($this->in_goods_tag and in_array($tag_val['tag_id'], $this->in_goods_tag)) echo 'checked="checked"'; ?> value="<?php echo $tag_val['tag_id']; ?>" ><?php echo $tag_val['tag_name']; ?></label>
                                <?php } } ?>
            				</div>
                        </div>
                        <?php } } ?>                                         
                  	</div>
                </div>
                
				<div id="goods_k" class="tab-pane" >
                	<div class="well admin_add_header_well"><?php echo $this->translate('商品属性'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品属性组'); ?>：</label>
           					<div class="controls">
                            	<select name="attribute_group_id" id="attribute_group_id" onchange="show_attribute_input();" class="span2">
                                <option value="0"><?php echo $this->translate('选择属性组'); ?></option>
                                <?php
                                if ($this->attribute_group) {
									foreach($this->attribute_group as $g_val) {	
								?>
								<option value="<?php echo $g_val['attribute_group_id']; ?>" <?php if ($this->goods_info and $g_val['attribute_group_id']==$this->goods_info->attribute_group_id) { ?>selected="selected"<?php } ?>><?php echo $this->escapeHtml($g_val['attribute_group_name']); ?></option>
                                <?php
									}
								}
								?>
                                </select>            				
            				</div>                   			                        
                        </div>
                        <div id="attribute_input_show">
                        <?php if(isset($this->attribute_html) and $this->attribute_html != '') echo $this->attribute_html; ?>
                        </div>                                         
                  	</div>
                </div>
                
				<div id="goods_j" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('商品评价'); ?></div>
                	<div class="well admin_add_well" style="padding:2px;">
                	    <div class="message_one">
                    	</div>
                        <table class="table table-hover" id="list_comment_show">

                        </table>                                          
                  	</div>
                </div>
                
                 <div id="goods_g" class="tab-pane" style="display: none">
                	<div class="well admin_add_header_well"><?php echo $this->translate('搜索引擎优化'); ?></div>
                	<div class="well admin_add_well">
                	    <div class="message_one">
                    	</div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品关键词'); ?>：</label>
           					<div class="controls">
              					<textarea class="span12" name="goods_keywords" id="goods_keywords" rows="2"><?php echo ($this->goods_info ? $this->escapeHtml($this->goods_info->goods_keywords) : ''); ?></textarea>
            				</div>                        
                        </div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品描述'); ?>：</label>
           					<div class="controls">
              					<textarea class="span12" name="goods_description" id="goods_description" rows="4"><?php echo ($this->goods_info ? $this->escapeHtml($this->goods_info->goods_description) : ''); ?></textarea>
            				</div>                        
                        </div>                                          
                  	</div>
                </div>                                         
              </div>
              </form>
</div>
<link href="<?php echo $this->basePath('public/js/jquery-autocomplete/jquery.autocomplete.css'); ?>" rel="stylesheet">
<script src="<?php echo $this->basePath('public/js/jquery-autocomplete/jquery.autocomplete.min.js'); ?>"></script>

<script src="<?php echo $this->basePath('/public/js/DatePicker/WdatePicker.js'); ?>"></script>

<script>
    //编辑器中使用
    var DBSHOP_GOODS_ID   = <?php echo ($this->goods_info ? $this->goods_info->goods_id : 0); ?>;
    var DBSHOP_SESSION_ID = '<?php echo md5(session_id()); ?>';
    var DBSHOP_LANGUAGE   = '<?php echo $this->dbshop_language; ?>';
</script>
<?php echo $this->partial('common/editor',array('edit_array'=>array('goods_body'))); ?>

<?php if ($this->success_msg != '') { ?>
<script>
show_message('.message_one','<?php echo date("Y-m-d H:i:s",time()); ?>','<?php echo $this->success_msg; ?>','alert-success');
</script>
<?php } ?>

<script type="text/javascript">
//商品保存验证
$(document).ready(function() {
	$("#form_goods_add").validate({
		rules: {
			goods_name: {
				required: true,
				minlength:2,
				maxlength:80
			},
			goods_shop_price: {
				required:true,
				number:true,
				maxlength:20,
				min:0
			},
			goods_type: {
				required:true
			},
			goods_stock: {
				required:true,
				digits:true,
				maxlength:11
			},
			//上面为必填，下面为非必填
			goods_weight: {
				number:true,
				maxlength:20,
				min:0
			},
			goods_info: {
				maxlength:600
			},
			goods_price: {
				number:true,
				maxlength:20,
				min:0
			},
			goods_preferential_price: {
				number:true,
				maxlength:20,
				min:0
			},
			goods_out_of_stock_set: {
				digits:true,
				maxlength:11
			},
			goods_cart_buy_min_num: {
				digits:true,
				maxlength:11
			},
			goods_cart_buy_max_num: {
				digits:true,
				maxlength:11
			},
			goods_extend_name: {
				maxlength:80
			},
			goods_keywords: {
				maxlength:200
			},
			goods_description: {
				maxlength:500
			},
			virtual_sales: {
				number:true,
				min:0
			},
			goods_integral_num: {
				number:true,
				min:0
			}
		},
		messages: {
			goods_name: {
				required: "<?php echo $this->translate('商品名称不能为空！'); ?>",
				minlength:"<?php echo $this->translate('商品名称最少两个字符！'); ?>",
				maxlength:"<?php echo $this->translate('商品名称最长80个字符！'); ?>"
			},
			goods_shop_price: {
				required: "<?php echo $this->translate('本店价格不能为空！'); ?>",
				number:"<?php echo $this->translate('价格必须为数字！'); ?>",
				maxlength:"<?php echo $this->translate('价格最长20个数字！'); ?>",
				min:"<?php echo $this->translate('本店价格最小为0！'); ?>"
			},
			goods_type: {
				required: "<?php echo $this->translate('商品类型不能为空！'); ?>"
			},
			goods_stock: {
				required:"<?php echo $this->translate('库存不能为空！'); ?>",
				digits:"<?php echo $this->translate('库存必须为整数！'); ?>",
				maxlength:"<?php echo $this->translate('数量最多11个字符！'); ?>"
			},
			//上面为必填，下面为非必填
			goods_weight: {
				number:"<?php echo $this->translate('重量必须为数字！'); ?>",
				maxlength:"<?php echo $this->translate('重量最长20个数字！'); ?>",
				min:"<?php echo $this->translate('重量最小为0！'); ?>"
			},
			goods_info: {
				maxlength:"<?php echo $this->translate('商品简述最多600个字符！'); ?>"
			},
			goods_price: {
				number:"<?php echo $this->translate('市场价格必须为数字！'); ?>",
				maxlength:"<?php echo $this->translate('市场价格最长20个数字！'); ?>",
				min:"<?php echo $this->translate('市场价格最小为0！'); ?>"
			},
			goods_preferential_price: {
				number:"<?php echo $this->translate('优惠价格必须为数字！'); ?>",
				maxlength:"<?php echo $this->translate('优惠价格最长20个数字！'); ?>",
				min:"<?php echo $this->translate('优惠价格最小为0！'); ?>"
			},
			goods_out_of_stock_set: {
				digits:"<?php echo $this->translate('必须输入整数！'); ?>",
				maxlength:"<?php echo $this->translate('数量最多11个字符！'); ?>"
			},
			goods_cart_buy_min_num: {
				digits:"<?php echo $this->translate('必须输入整数！'); ?>",
				maxlength:"<?php echo $this->translate('数量最多11个字符！'); ?>"
			},
			goods_cart_buy_max_num: {
				digits:"<?php echo $this->translate('必须输入整数！'); ?>",
				maxlength:"<?php echo $this->translate('数量最多11个字符！'); ?>"
			},
			goods_extend_name: {
				maxlength:"<?php echo $this->translate('扩展标题最多80个字符！'); ?>"
			},
			goods_keywords: {
				maxlength:"<?php echo $this->translate('商品关键字最多200个字符！'); ?>"
			},
			goods_description: {
				maxlength:"<?php echo $this->translate('商品描述最多500个字符！'); ?>"
			},
			virtual_sales: {
				number:"<?php echo $this->translate('虚拟销量必须为数字！'); ?>",
				min:"<?php echo $this->translate('虚拟销量最小为0！'); ?>"
			},
			goods_integral_num: {
				number:"<?php echo $this->translate('积分购买必须为数字！'); ?>",
				min:"<?php echo $this->translate('积分购买最小为0！'); ?>"
			}
		}
	});
});

//商品删除
function goods_del_js(goods_id) {
	if(window.confirm('<?php echo $this->translate('您确实要删除该商品吗？'); ?>')) {
	$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'del','controller'=>'goods')); ?>",{goods_id:goods_id},
		function(data){
			if(data != 'false') {
				window.location.href='<?php echo $this->url('goodsetutor/default',array('controller'=>'goods')); ?>';
				return true;
			} else {
				alert('<?php echo $this->translate('商品删除失败！'); ?>');
			}
		});
	}
	return false;
}
//属性输入显示
function show_attribute_input() {
	var attribute_group_id = $('#attribute_group_id').val();
	var goods_id		   = $('#goods_id').val();
	$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'attributeInput')); ?>",{attribute_group_id:attribute_group_id,goods_id:goods_id},
			function(data){
				$("#attribute_input_show").html(data);
				return true;
			});	
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function edit_image_slide_state(goods_image_id, image_slide_input) {
    if($('#'+image_slide_input).attr("checked")){
        var image_slide_value= 1;
    } else {
        var image_slide_value= 2;
    }
    $.post("<?php echo $this->url('goodsetutor/default',array('action'=>'updateimage')); ?>",{goods_image_id:goods_image_id,image_slide_value:image_slide_value},
        function(data){
            if(data != 'false') {
                return true;
            } else {
                if (image_slide_value == 1) $('#'+image_slide_input).attr("checked", false);
                if (image_slide_value == 2) $('#'+image_slide_input).attr("checked", true);

                alert('<?php echo $this->translate('更新显示失败！'); ?>');
            }
        });
}
//商品图片更新

function edit_goods_image(goods_image_id,image_sort_input,image_slide_input,goods_image_name) {
	var image_sort_value = $('#'+image_sort_input).val();
    var default_image    = $('input[name="default_image"]:checked').val();

    if($('#'+image_slide_input).attr("checked") || default_image == goods_image_id){
        var image_slide_value= 1;
        $('#'+image_slide_input).attr("checked", 'true');
    } else {
        var image_slide_value= 2;
    }

	if(!/^[0-9]+(.[0-9]*)?$/.test(image_sort_value)) {
		alert('<?php echo $this->translate('图片排序必须为数字！'); ?>');
		$("#"+image_sort_input).focus();
		return false;
	}
	if(image_sort_value > 255 || image_sort_value < 0) {
		alert('<?php echo $this->translate('图片排序不能大于255或小于0'); ?>');
		$("#"+image_sort_input).focus();
		return false;
	}

	$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'updateimage')); ?>",{goods_image_id:goods_image_id,image_sort:image_sort_value,image_slide_value:image_slide_value},
	function(data){
		if(data != 'false') {
			show_message('#image_message_one','<?php echo date("Y-m-d H:i:s",time()); ?>','<?php echo $this->translate('图片'); ?>'+goods_image_name+'<?php echo $this->translate('更新成功！'); ?>','alert-success');
			return true;
		} else {
			alert('<?php echo $this->translate('图片'); ?>'+goods_image_name+'<?php echo $this->translate('更新失败！'); ?>');
		}
	});
}
//商品图片删除
function del_goods_image(image_id,goods_image_name) {
	if(window.confirm('<?php echo $this->translate('您确实删除图片'); ?>'+goods_image_name+'？')) {
		$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'delimage')); ?>",{goods_image_id:image_id},
		function(data){
			if(data != 'false') {
				$("#image_"+image_id).remove();
				return true;
			} else {
				alert('<?php echo $this->translate('图片'); ?>'+goods_image_name+'<?php echo $this->translate('删除失败！'); ?>');
			}
		});
	}
	return false;
}

<?php $timestamp = time();?>
$(function() {
    $('#file_upload').uploadifive({
        'auto'             : true,
        'removeCompleted'  : true,
        'formData'         : {
            'timestamp' : '<?php echo $timestamp;?>',
            'token'     : '<?php echo md5('unique_salt' . $timestamp);?>',
            'editSession': DBSHOP_SESSION_ID
        },
        'successTimeout'   : 30,
        'buttonText'       : '<?php echo $this->translate('上传商品图片'); ?>',
        'queueID'          : 'queue',
        'uploadScript'     : '<?php echo $this->url('goodsetutor/default',array('action'=>'addimage')); ?>',
        'onUploadComplete' : function(file, data) {
            if(!data.match("^\{(.+:.+,*){1,}\}$")) {
                alert(data);
                return false;
            }
            data = jQuery.parseJSON(data);

            var image_path = '';
            if(data.yun_type == 'yun') {
                image_path = '';
            } else {
                image_path = '<?php echo rtrim($this->basePath('/'), '/'); ?>';
            }

            var image_html = '<tr id="image_'+data.image_id+'">';
            image_html = image_html+'<td><img src="'+image_path+data.image_name+'" style="width: 100px;" broder=0></td>';
            image_html = image_html+'<td style="vertical-align:middle">'+data.image+'<input type="hidden" name="image_more[]" value="'+data.image_id+'"></td>';
            image_html = image_html+'<td style="vertical-align:middle"><input type="radio" name="default_image" value="'+data.image_id+'"></td>';
            image_html = image_html+'<td style="vertical-align:middle"><label class="checkbox"><input type="checkbox" checked name="image_slide_'+data.image_id+'" id="image_slide_'+data.image_id+'" onclick="edit_image_slide_state('+data.image_id+', \'image_slide_'+data.image_id+'\');" value="1"></label></td>';
            image_html = image_html+'<td style="vertical-align:middle"><input type="text" class="span4" name="image_sort_'+data.image_id+'" id="image_sort_'+data.image_id+'" value="255" /></td>';
            image_html = image_html+'<td style="vertical-align:middle"><a href="javascript:;" onclick="edit_goods_image('+data.image_id+',\'image_sort_'+data.image_id+'\',\'image_slide_'+data.image_id+'\',\''+data.image+'\');" class="btn btn-small btn-primary"><i class="icon-refresh icon-white"></i> <?php echo $this->translate('更新'); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="del_goods_image('+data.image_id+',\''+data.image+'\');" class="btn btn-small btn-danger"><i class="icon-trash icon-white"></i> <?php echo $this->translate('删除'); ?></a></td>';
            image_html = image_html+'</tr>';
            $('#goods_more_image').prepend(image_html);
            return true;
        }
    });
});

function get_editor_new_image(goods_id) {

    var image_id = '';
    $("input[name='image_more[]']").each(function() {
        if(this.value != 0) {
            image_id += this.value + '|';
        }
    })

    $.post("<?php echo $this->url('goodsetutor/default',array('action'=>'getEditorImage')); ?>",{goods_id:goods_id, editor_session_str:DBSHOP_SESSION_ID, image_id:image_id},
        function(data){
            if(data != null) {
                var image_path = '';
				var image_html = '';
                for(var i=0; i<data.length; i++) {
                    if(data[i].yun_type == 'yun') {
                        image_path = '';
                    } else {
                        image_path = '<?php echo rtrim($this->basePath('/'), '/'); ?>';
                    }

                    image_html = image_html+'<tr id="image_'+data[i].goods_image_id+'">';
                    image_html = image_html+'<td><img src="'+image_path+data[i].goods_thumbnail_image+'" style="width: 100px;" broder=0></td>';
                    image_html = image_html+'<td style="vertical-align:middle">'+data[i].image_name+'<input type="hidden" name="image_more[]" value="'+data[i].goods_image_id+'"></td>';
                    image_html = image_html+'<td style="vertical-align:middle"><input type="radio" name="default_image" value="'+data[i].goods_image_id+'"></td>';
                    image_html = image_html+'<td style="vertical-align:middle"><label class="checkbox"><input type="checkbox" '+data[i].checked+' name="image_slide_'+data[i].goods_image_id+'" id="image_slide_'+data[i].goods_image_id+'" onclick="edit_image_slide_state('+data[i].goods_image_id+', \'image_slide_'+data[i].goods_image_id+'\');" value="1"></label></td>';
                    image_html = image_html+'<td style="vertical-align:middle"><input type="text" class="span4" name="image_sort_'+data[i].goods_image_id+'" id="image_sort_'+data[i].goods_image_id+'" value="'+data[i].image_sort+'" /></td>';
                    image_html = image_html+'<td style="vertical-align:middle"><a href="javascript:;" onclick="edit_goods_image('+data[i].goods_image_id+',\'image_sort_'+data[i].goods_image_id+'\',\'image_slide_'+data[i].goods_image_id+'\',\''+data[i].image_name+'\');" class="btn btn-small btn-primary"><i class="icon-refresh icon-white"></i> <?php echo $this->translate('更新'); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="del_goods_image('+data[i].goods_image_id+',\''+data[i].image_name+'\');" class="btn btn-small btn-danger"><i class="icon-trash icon-white"></i> <?php echo $this->translate('删除'); ?></a></td>';
                    image_html = image_html+'</tr>';
                }
				$('#goods_more_image').prepend(image_html);
            } else {
                alert('<?php echo $this->translate('无新的商品图片'); ?>');
            }
        },'json');
}

<?php if (isset($this->goods_info) and $this->goods_info->goods_id != '')  { ?>
//ajax获取列表信息
dbshop_ajax_list('<?php echo $this->url('comment/default/goods-id',array('action'=>'ajaxcomment','controller'=>'comment','goods_id'=>$this->goods_info->goods_id)); ?>', 'list_comment_show');

//ajax删除单个评价
function del_one_comment(comment_id, goods_id) {
	if(window.confirm('<?php echo $this->translate('您确实要删除该条评价吗？'); ?>')) {
	$.post("<?php echo $this->url('comment/default',array('action'=>'ajaxdelonecomment')); ?>",{goods_id:goods_id,comment_id:comment_id},
		function(data){
			if(data != 'false') {
				dbshop_ajax_list('<?php echo $this->url('comment/default/goods-id',array('action'=>'ajaxcomment','controller'=>'comment','goods_id'=>$this->goods_info->goods_id)); ?>', 'list_comment_show');
				return true;
			} else {
				alert('<?php echo $this->translate('评价删除失败！'); ?>');
			}
		});
	}
	return false;	
}

//jquery-autocomplete查询商品
$("#related_goods_keyword").autocomplete("<?php echo $this->url('goodsetutor/default',array('action'=>'autocompleteGoodsSearch')); ?>", {
	//mustMatch: true,
	max: 20,
	minChars:1,
	scrollHeight:400
});
$("#related_goods_keyword").result(function(event, data, formatted) {
	if (data) $("#relatedgoods_id").val(data[1]);
});
//添加相关商品
function add_related_goods_js() {
	var goods_id 	     = $('#goods_id').val();
	var related_goods_id = $('#relatedgoods_id').val();
	if(related_goods_id == '') {
		alert('<?php echo $this->translate('该商品不存在，请从新选择！'); ?>');
		return false;	
	}
	$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'addRelatedGoods')); ?>",{goods_id:goods_id,related_goods_id:related_goods_id},
		function(data){
			if(data.state == 'true') {
				var html_table = '<tr id="show_related_goods_'+data.related_id+'">';
				html_table = html_table + '<td>'+data.related_goods_id+'</td>';
				html_table = html_table + '<td>'+data.goods_name+'</td>';
				html_table = html_table + '<td>'+data.goods_item+'</td>';
				html_table = html_table + '<td>'+data.goods_shop_price+'</td>';
				html_table = html_table + '<td>'+data.goods_state+'</td>';
				html_table = html_table + '<td><a href="javascript:;" onclick="delete_related_goods('+data.related_id+');"><?php echo $this->translate('删除'); ?></a></td>';
				html_table = html_table + '</tr>';
				$('#related_goods_table').prepend(html_table);
				$('#related_goods_keyword').val('');
				$('#related_goods_id').val('');
			} else if(data.state == 'have') {
				alert('<?php echo $this->translate('该相关商品已经存在，无需再次添加！'); ?>');
			} else {
				alert('<?php echo $this->translate('相关商品添加失败！'); ?>');
			}
		},'json');
}
//删除相关商品
function delete_related_goods(related_id) {
	if(window.confirm('<?php echo $this->translate('您确实要删除该相关商品吗？'); ?>')) {
		$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'delRelatedGoods')); ?>",{related_id:related_id},
		function(data){
			if(data == 'true') {
				$("#show_related_goods_"+related_id).remove();
			} else {
				alert('<?php echo $this->translate('相关商品删除失败！'); ?>');
			}
		});		
	}
}
//jquery-autocomplete查询组合商品
$("#combination_goods_keyword").autocomplete("<?php echo $this->url('goodsetutor/default',array('action'=>'autocompleteGoodsSearch')); ?>", {
	//mustMatch: true,
	max: 20,
	minChars:1,
	scrollHeight:400
});
$("#combination_goods_keyword").result(function(event, data, formatted) {
	if (data) {
		$("#combination_goods_id").val(data[1]);
	}
});
//添加组合商品
function add_combination_goods_js() {
	var goods_id 	     	 = $('#goods_id').val();
	var combination_goods_id = $('#combination_goods_id').val();
	if(combination_goods_id == '') {
		alert('<?php echo $this->translate('该商品不存在，请从新选择！'); ?>');
		return false;	
	}
	$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'addCombinationGoods')); ?>",{goods_id:goods_id,combination_goods_id:combination_goods_id},
		function(data){
			if(data.state == 'true') {
				var html_table = '<tr id="show_combination_goods_'+data.combination_id+'">';
				html_table = html_table + '<td>'+data.combination_goods_id+'</td>';
				html_table = html_table + '<td>'+data.goods_name+'</td>';
				html_table = html_table + '<td>'+data.goods_item+'</td>';
				html_table = html_table + '<td>'+data.goods_shop_price+'</td>';
				html_table = html_table + '<td>'+data.goods_state+'</td>';
				html_table = html_table + '<td><a href="javascript:;" onclick="delete_combination_goods('+data.combination_id+');"><?php echo $this->translate('删除'); ?></a></td>';
				html_table = html_table + '</tr>';
				$('#combination_goods_table').prepend(html_table);
				$('#combination_goods_keyword').val('');
				$('#combination_goods_id').val('');
			} else if(data.state == 'have') {
				alert('<?php echo $this->translate('该组合商品已经存在，无需再次添加！'); ?>');
			} else {
				alert('<?php echo $this->translate('组合商品添加失败！'); ?>');
			}
		},'json');
}
//删除组合商品
function delete_combination_goods(combination_id) {
	if(window.confirm('<?php echo $this->translate('您确实要删除该组合商品吗？'); ?>')) {
		$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'delCombinationGoods')); ?>",{combination_id:combination_id},
		function(data){
			if(data == 'true') {
				$("#show_combination_goods_"+combination_id).remove();
			} else {
				alert('<?php echo $this->translate('组合商品删除失败！'); ?>');
			}
		});		
	}
}

//jquery-autocomplete查询商品
$("#relation_goods_keyword").autocomplete("<?php echo $this->url('goodsetutor/default',array('action'=>'autocompleteGoodsSearch')); ?>", {
	//mustMatch: true,
	max: 20,
	minChars:1,
	scrollHeight:400
});
$("#relation_goods_keyword").result(function(event, data, formatted) {
	if (data) $("#relationgoods_id").val(data[1]);
});
//添加关联商品
function add_relation_goods_js() {
	var goods_id 	     = $('#goods_id').val();
	var relation_goods_id = $('#relationgoods_id').val();
	if(relation_goods_id == '') {
		alert('<?php echo $this->translate('该商品不存在，请从新选择！'); ?>');
		return false;
	}
	$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'addRelationGoods')); ?>",{goods_id:goods_id,relation_goods_id:relation_goods_id},
			function(data){
				if(data.state == 'true') {
					var html_table = '<tr id="show_relation_goods_'+data.relation_id+'">';
					html_table = html_table + '<td>'+data.relation_goods_id+'</td>';
					html_table = html_table + '<td>'+data.goods_name+'</td>';
					html_table = html_table + '<td>'+data.goods_item+'</td>';
					html_table = html_table + '<td>'+data.goods_shop_price+'</td>';
					html_table = html_table + '<td>'+data.goods_state+'</td>';
					html_table = html_table + '<td><input type="text" name="relation_sort['+data.relation_id+']" value="'+data.relation_sort+'"></td>';
					html_table = html_table + '<td><a href="javascript:;" onclick="delete_relation_goods('+data.relation_id+');"><?php echo $this->translate('删除'); ?></a></td>';
					html_table = html_table + '</tr>';
					$('#relation_goods_table').prepend(html_table);
					$('#relation_goods_keyword').val('');
					$('#relationgoods_id').val('');
				} else if(data.state == 'have') {
					alert('<?php echo $this->translate('该关联商品已经存在，无需再次添加！'); ?>');
				} else {
					alert('<?php echo $this->translate('关联商品添加失败！'); ?>');
				}
			},'json');
}
//删除相关商品
function delete_relation_goods(relation_id) {
	if(window.confirm('<?php echo $this->translate('您确实要删除该关联商品吗？'); ?>')) {
		$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'delRelationGoods')); ?>",{relation_id:relation_id},
				function(data){
					if(data == 'true') {
						$("#show_relation_goods_"+relation_id).remove();
					} else {
						alert('<?php echo $this->translate('关联商品删除失败！'); ?>');
					}
				});
	}
}
<?php } ?>

//将商品价格转换为积分
function price_change_integral(priceId, integralId) {
    var goods_price = $('#'+priceId).val();
    if(goods_price == '') { alert('<?php echo $this->translate('请先输入商品价格！'); ?>'); return; }
    $.post("<?php echo $this->url('integral/default',array('action'=>'goodsPriceChangeIntegral')); ?>",{price:goods_price},
        function(data){
            if(data == 'false') {
                alert('<?php echo $this->translate('积分转换失败！'); ?>');
            } else {
                $('#'+integralId).val(data);
            }
        });
}

//商品分类选择处理
function select_goods_class(class_path, class_id) {
    if($("#class_id_"+class_id).attr("checked")) {
        var class_array = new Array();
        class_array     = class_path.split(",");
        for(i=0; i<class_array.length; i++) {
            if(class_array[i] != class_id) $("#class_id_"+class_array[i]).attr("checked", "true");
        }
    }
}

<?php if(isset($this->get_class_info) and $this->get_class_info->class_top_id != 0) { ?>
select_goods_class('<?php echo $this->get_class_info->class_path; ?>', '<?php echo $this->get_class_info->class_id; ?>');
<?php } ?>


function select_goods_spec_tag_group(tag_group_id, tag_group_name) {
	if($("#goods_spec_tag_group_"+tag_group_id).attr("checked")) {
	$.post("<?php echo $this->url('goodsetutor/default',array('action'=>'goodsSpecTagGroup')); ?>",{tag_group_id:tag_group_id},
			function(data){
				if(data.state == 'true') {
					var html_s = '<div class="control-group" id="select_tag_group_'+tag_group_id+'">';
					html_s += '<label for="input01" class="control-label">'+data.tag_group_name+'：</label>';
					if(data.tag.length > 0) {
						html_s += '<div class="controls">';
						for(i=0; i<data.tag.length; i++) {
							html_s += '<label class="checkbox inline"><input type="checkbox" name="spec_goods_tag_'+tag_group_id+'[]" id="spec_goods_tag_'+tag_group_id+'_'+data.tag[i].tag_id+'" value="'+data.tag[i].tag_id+'" onclick="add_goods_spec_tag('+data.tag[i].tag_id+', '+tag_group_id+', \''+data.tag[i].tag_name+'\', \''+data.tag_group_name+'\');">';
							if(data.tag[i].tag_str) {
								html_s += '<span style="background-color: '+data.tag[i].tag_str+';height: 14px;width: 14px;border: 1px solid #E4E4E4;display:inline-block;line-height: 20px;vertical-align: middle;"></span>';
							}
							html_s += '<span id="name'+data.tag[i].tag_id+'">'+data.tag[i].tag_name+'</span></label>';
						}
						html_s += '</div>';
					}
					html_s += '</div>';

					$('#select_goods_spec_tag').prepend(html_s);
				}
			},'json');
	} else {
		$('#select_tag_group_'+tag_group_id).remove();
		add_goods_spec_tag('', tag_group_id, '', tag_group_name);
	}
}

var select_spec_tag_num = <?php echo ($spec_goods_tag_state ? '1' : '0'); ?>;
function add_goods_spec_tag(tag_id, tag_group_id, tag_name, tag_group_name) {
    var g_s_s = false;//用于判断是否有选中的规格，默认是无
	var goods_spec_array	= new Array();
	$("input[name='goods_spec_tag_group[]']").each(function() {
		if(this.checked == true) {
			var group_value = this.value;
			var add_state	= false;
			$("input[name='spec_goods_tag_"+this.value+"[]']").each(function() {
				if(this.checked == true && !add_state) {
					add_state = true;
					var goods_spec_object	= new Object();
					goods_spec_object.tag_group_id = group_value;
					goods_spec_object.tag_group_name = $('#goods_spec_tag_group_name_'+group_value).html();
					goods_spec_array.push(goods_spec_object);
                    g_s_s = true;//说明有选中的规格
				}
			});

		}
	});
	//判断是否有选中，这里主要用于提交时对于价格和库存是否为空的判断
	if(g_s_s) select_spec_tag_num = 1;
	else select_spec_tag_num = 0;
	//用于同步修改商品标签选择
    if(tag_id != '') {
        if($("#spec_goods_tag_"+tag_group_id+"_"+tag_id).attr("checked")) {
            $("#tag_id_"+tag_id).attr("checked", 'true');
        } else {
            $("#tag_id_"+tag_id).removeAttr("checked");
        }
    }

	var html_table_th = '<tr>';
	var group_array = new Array();
	var group_object = [];
	for(i=0; i<goods_spec_array.length; i++) {
		var tag_array = new Array();
		$("input[name='spec_goods_tag_"+goods_spec_array[i].tag_group_id+"[]']").each(function() {
			if(this.checked == true) {
				if(!group_object[this.value]) group_object[this.value] = $('#name'+this.value).html();
				//tag_array.push($('#name'+this.value).html());
				tag_array.push(this.value);
			}
		});
		if(tag_array.length > 0) {
			group_array.push(tag_array);
		}

		html_table_th += '<th width="8%">'+goods_spec_array[i].tag_group_name+'</th>';
	}
	html_table_th += '<th width="12%"><?php echo $this->translate('价格'); ?><span class="must_add_value">*</span>&nbsp;<input type="text" class="span8" id="spec_tag_goods_price" onblur="edit_price_stock(\'spec_tag_goods_price\', \'price\');" /></th>';
	html_table_th += '<th width="10%"><?php echo $this->translate('库存'); ?><span class="must_add_value">*</span>&nbsp;<input type="text" class="span8" id="spec_tag_goods_stock" onblur="edit_price_stock(\'spec_tag_goods_stock\', \'stock\');" /></th>';
	html_table_th += '<th width="10%" style="vertical-align:middle;"><?php echo $this->translate('商品货号'); ?>&nbsp;<input type="text" class="span5" id="edit_goods_item" onblur="edit_goods_item_all();" /></th>';
	html_table_th += '<th width="8%"><?php echo $this->translate('积分购买'); ?></th>';
	html_table_th += '<th width="15%"><?php echo $this->translate('会员价格'); ?></th>';
	html_table_th += '</tr>';

	$("#select_goods_color_size_in").css('display','');
	$('#goods_spec_th').html(html_table_th);

	var td_array = descartes(group_array);
	var html_table_td = '';
	for(i=0; i < td_array.length; i++) {
		var tag_id_str = '';
		html_table_td += '<tr>';
		var td_i_array = td_array[i];
		if(goods_spec_array.length <= 1) {
			tag_id_str += '_'+td_i_array;
			html_table_td += '<td>'+group_object[td_i_array]+'</td>';
		} else {
			for(n=0; n < td_i_array.length; n++) {
			 //tag_id_str	 += '_'+td_i_array[n];
			 html_table_td += '<td>'+group_object[td_i_array[n]]+'</td>';
			 }
             td_i_array.sort(sortNumber);
			var td_i_str = td_i_array.toString();
            tag_id_str = '_'+td_i_str.replace(/,/g, '_');
		}

		var price_val = $("#price"+tag_id_str).val() ? $("#price"+tag_id_str).val() : '';
		var stock_val = $("#stock"+tag_id_str).val() ? $("#stock"+tag_id_str).val() : '';
		var item_val = $("#item"+tag_id_str).val() ? $("#item"+tag_id_str).val() : '';
		var integral_val = $("#integral_num"+tag_id_str).val() ? $("#integral_num"+tag_id_str).val() : '';

		html_table_td += '<td><input type="hidden" name="spec_tag_id_str[]" value="'+tag_id_str+'"><input type="text" name="spec_goods_price[]" id="price'+tag_id_str+'" value="'+price_val+'"></td>';
		html_table_td += '<td><input type="text" name="spec_goods_stock[]" id="stock'+tag_id_str+'" value="'+stock_val+'"></td>';
		html_table_td += '<td><input type="text" name="spec_goods_item[]" id="item'+tag_id_str+'" value="'+item_val+'"></td>';

        html_table_td += '<td><input type="text" id="integral_num'+tag_id_str+'" name="integral_num[]" style="width: 80px;" readonly value="'+integral_val+'">';
        html_table_td += '<p><button type="button" class="btn btn-small btn-primary" onclick="price_change_integral(\'price'+tag_id_str+'\',\'integral_num'+tag_id_str+'\');"><?=$this->translate('换算'); ?></button>&nbsp;';
        html_table_td += '<button type="button" class="btn btn-small btn-danger" onclick="$(\'#integral_num'+tag_id_str+'\').val(0);"><?=$this->translate('取消'); ?></button></p></td>';

		html_table_td += '<td>';
		<?php
    if(isset($this->user_group) and !empty($this->user_group)) {
?>
		html_table_td = html_table_td + '<table style="border: 1px solid #ddd;width: 100%;">';
		<?php
                foreach($this->user_group as $userGroupValue){
        ?>
        var group_price_val = $("#groupprice"+tag_id_str+"_<?php echo $userGroupValue['group_id']; ?>").val() ? $("#groupprice"+tag_id_str+"_<?php echo $userGroupValue['group_id']; ?>").val() : '0';
		html_table_td = html_table_td + '<tr><td><?php echo $this->escapeHtml($userGroupValue['group_name']); ?></td><td><input type="text" id="groupprice'+tag_id_str+'_<?php echo $userGroupValue['group_id']; ?>" name="spec_goods_group_price['+tag_id_str+'][<?php echo $userGroupValue['group_id']; ?>]" value="'+group_price_val+'"></td></tr>';
		<?php } ?>
		html_table_td = html_table_td + '</table>';
		<?php } ?>
		html_table_td += '</td></tr>';
	}
	$('#goods_spec_td').html('');
	$('#goods_spec_td').html(html_table_td);

	if(goods_spec_array.length <= 0) {
		$("#select_goods_color_size_in").css('display','none');
	}
}
//扩展列表，商品价格和库存统一修改
function edit_price_stock(edit_id, edit_str) {
    var edit_value = $('#'+edit_id).val();

    $("input[name='spec_tag_id_str[]']").each(function() {
        if(!$("#"+edit_str+this.value).val() || $("#"+edit_str+this.value).val() == 0) {
            $("#"+edit_str+this.value).val(edit_value);
        }
    })
}
//商品货号批量修改
function edit_goods_item_all() {
    var edit_goods_item_value = $('#edit_goods_item').val();
    var item_num = 1;
    $("input[name='spec_tag_id_str[]']").each(function() {
        if((!$("#item"+this.value).val() || $("#item"+this.value).val() == 0) && edit_goods_item_value) {
            $("#item"+this.value).val(edit_goods_item_value+'-'+item_num);
            item_num++;
        }
    })
}
//对最终的结果进行检测
function check_size_goods() {
    if(select_spec_tag_num != 0) {
        var error_message = '';
        $("input[name='spec_goods_price[]']").each(function() {
            if(!/^[0-9]+(.[0-9]*)?$/.test($(this).val()) || $(this).val() < 0) {
                error_message = '<?php echo $this->translate('销售规格中的商品价格不能为空，且不能小于0！'); ?>';
                $(this).focus();
                return false;
            }
        })
        if(error_message) { alert(error_message); return false; }

        $("input[name='spec_goods_stock[]']").each(function() {
            if(!/^\d+$/.test($(this).val()) || $(this).val() < 0) {
                error_message = '<?php echo $this->translate('销售规格中的商品库存不能为空,且必须为数字不能小于0！'); ?>';
                $(this).focus();
                return false;
            }
        })
        if(error_message) { alert(error_message); return false; }

    }
    return true;
}
/**
 * 笛卡尔积换算
 * @param {array} [arguments] 多个数组, 如：[[1, 2, 3, 4], [11, 22, 33, 44]]
 * @author Flc
 * @example
 *     descartes([[1, 2, 3, 4], [11, 22, 33, 44], [111, 222, 333, 444]]);
 */
function descartes(args){
	//var args = arguments;
	var rs   = [];

	// A. 校验并转换为JS数组
	for (var i = 0; i < args.length; i++) {
		if (!$.isArray(args[i])) {
			return false;  // 参数必须为数组
		}
	}

	// 两个笛卡尔积换算
	var bothDescartes = function (m, n){
		var r = []
		for (var i = 0; i < m.length; i++) {
			for (var ii = 0; ii < n.length; ii++) {
				var t = [];
				if ($.isArray(m[i])) {
					t = m[i].slice(0);  //此处使用slice目的为了防止t变化，导致m也跟着变化
				} else {
					t.push(m[i]);
				}
				t.push(n[ii]);
				r.push(t);
			}
		}
		return r;
	}

	// 多个笛卡尔基数换算
	for (var i = 0; i < args.length; i++) {
		if (i == 0) {
			rs = args[i];
		} else {
			rs = bothDescartes(rs, args[i]);
		}
	}

	return rs;
}
//var strstr = descartes([['黑色', '红色', '白色', '绿色'], ['13寸', '14寸']]);

function sortNumber(a, b) {
return a - b
}
</script>